let url = "/index.php";
if (process.env.NODE_ENV == "development") {
  url = "/api";
}
export default (data) => {
  return new Promise((resolve, rejuct) => {
    uni.request({
      url: url + data.url,
      data: {
        uid: uni.getStorageSync("user").id,
        ...data.data,
      },
      method: data.method || "GET",
      header: {
        Accept: "text/json",
        "Content-Type": "application/json;charset=UTF-8",
        platform: "WechatMiniProgram",
        token: uni.getStorageSync("user").token,
      },

      success: (res) => {
        resolve(res.data);
        // if (res.data.code != 1)
        //   uni.showToast({
        //     mask: true,
        //     title: res.data.msg,
        //     icon: "none",
        //   });
      },
      fail: (err) => {
        console.log(err);
      },
    });
  });
};
